﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.Helpers;

namespace rndbuddy
{
    public partial class suggest_blackspot : Form
    {
        public suggest_blackspot()
        {
            InitializeComponent();
            lbl_radius.Text = inp_radius.Value.ToString();
            populate_data();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!checkBox1.Checked)
                return;

            populate_data();
        }

        private void populate_data()
        {
            if (!StyxWoW.IsInGame || !StyxWoW.IsInWorld)
                return;
            try
            {

                lbl_mapID.Text = StyxWoW.Me.MapId.ToString();
                lbl_zoneId.Text = StyxWoW.Me.ZoneId.ToString();
                lbl_x.Text = StyxWoW.Me.X.ToString();
                lbl_y.Text = StyxWoW.Me.Y.ToString();
                lbl_z.Text = StyxWoW.Me.Z.ToString();
            }
            catch (Exception)
            {
                //...
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(inp_info.Text))
            {
                MessageBox.Show("Please enter a description!", "Error", MessageBoxButtons.OK);
                return;
            }

            server_pipe.store_manual_blackspot(
                lbl_mapID.Text,
                lbl_zoneId.Text,
                lbl_x.Text,
                lbl_y.Text,
                lbl_z.Text,
                lbl_radius.Text,
                inp_info.Text
                );

            inp_info.Text = "";
            MessageBox.Show("OK, you can leave this window open to submit another blackspot");

        }

        private void inp_radius_ValueChanged(object sender, EventArgs e)
        {
            lbl_radius.Text = inp_radius.Value.ToString();
        }

    }
}
